<?php

require_once $_SERVER['srcPath'].'/Db.php';
require_once $_SERVER['srcPath'].'/ApplicationTCPConnection.php';
require_once 'TestUtils.php';
use GrouppaGroup\Db;
use GrouppaGroup\ApplicationTCPConnection;

$HTTP_RAW_POST_DATA;
$DEBUG=true;
class MainTest extends PHPUnit_Framework_TestCase
{
	private $lastUsersIndex;
	public function setUp()
	{

		$this->lastUsersIndex = TestUtils::getAutoIncrementValue('users');
	}
	public function testMain()
	{
		ApplicationTCPConnection::$responses = array();
		$HTTP_RAW_POST_DATA=array(83, 42, 72, 89, -99, 88, 127, 33, 56, 95, 127, -97, -77, 1, 11, 77, 113, 46, -49, 67, -43, 29, -83, 64, 49, 56, -59, 126, -30, -97, 88, -101, -93, -20, 118, -92, 61, 85, 33, -55, -27, -7, 62, 77, -98, -96, -47, 36, -109, -96, 120, 96, 40, 75, 126, 92, 27, -113, 68, 79, 81, -122, 37, 110, 17, 12, -107, -115, 68, -79, -92, -25, -44, -95, 1, 114, -13, 3, -28, 40, -59, -51, 53, 36, -5, -30, 40, -5, -94, -10, 22, 118, 104, -78, 71, 82, 107, -7, -104, 127, 112, 23, 64, -8, -126, -99, -19, -113, -122, 80, 61, -21, -17, 67, 27, 2, 83, -101, 21, -14, -52, -121, 14, 64, -66, -58, -61, 52, 3, 96, -85, -81, -26, 103, -57, -48, -80, 106, 3, 54, 9, -36, 86, -87, 46, 103, -27, 32, -6, -61, -21, 7, -57, -81, -113, -48, 111, -121, -106, 55, 36, 87, 116, -21, -37, 65, -120, 10, -1, 81, -11, 41, 106, -89, -49, -13);
		$HTTP_RAW_POST_DATA = implode(array_map("chr", $HTTP_RAW_POST_DATA));
		require $_SERVER['srcPath'].'\\grouppaMain.php';
	}

	public function tearDown()
	{
		//delete all created accounts
		Db::getInstance()->sendQuery("DELETE FROM users WHERE id_user >= {$this->lastUsersIndex}");
	}
}